import Vue from "vue"
import Router from "vue-router"

Vue.use(Router)

let router = new Router({
  routes: [{
    path:'/',
    name:"home",
    meta:{title:"主页"},
    component: () => import("@/views/Home.vue")
  },{
    path: '/login',
    name: "login",
    meta: {
      title: "登录",
      anonymous: true
    },
    component: () => import("@/views/Login.vue")
  }]
})
router.beforeEach((to, from, next) => {
  //ViewUI.LoadingBar.start();
  if (!to.meta.anonymous && !sessionStorage.getItem('loginuser')) {
    next('/login')
  }
  next();
});
router.afterEach((to) => {
  //ViewUI.LoadingBar.finish();
  document.title = to.meta.title
});
export default router